home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / ray_20 / ray2_0.txt < prev   
Text File  |  1992-12-09  |  6KB  |  145 lines

  1.  
  2.     This is the second version of a simple ray tracer written here at
  3. RPI.  The second version expanded its capabilities with the inclusion of
  4. distributed ray tracing.  Detailed information on what distributed ray
  5. tracing is can be found in the paper by Cook, Porter and Carpenter:
  6. "Distributed Ray Tracing", ACM Computer Graphics, Vol.18, Num.3, July 1984.
  7.     New capabilities include: Gloss (blurred reflection), translucency
  8. (blurred refraction), penumbras (area light sources), motion blur, square
  9. intersection routine and a field of view options.  The eye can be in any
  10. position now and can look towards any direction.  Antialising can also be
  11. done using stochastic sampling.  The old version was also supporting
  12. reflections, refractions and shadows using spheres.
  13.     Here is a list of the files, and what does each file contain:
  14.  
  15. bg.c:        bgcolor()    evaluates the background color for a given ray.
  16.  
  17. initialize.c:    initialize()    does some useful setup.
  18.  
  19. intersect.c:    sphere()    Intersection routine with a sphere.
  20.         quad()        Intersection routine with a square.
  21.         intersect()    Main intersection routine  (calls sphere() ).
  22.  
  23. main.c:        main()        Main body of the program.
  24.  
  25. readfile.c:    readfile()    Reads in the input data.
  26.  
  27. shade.c:    shadow()        Calculates the existance of a shadow ray.
  28.         reflect()    Find the reflection vector.
  29.         refract()    Find the refraction vector.
  30.         shade()        Calculate Phong's shading function.
  31.  
  32. trace.c:    quickcos()    Calculate a fast cos between 0 and pi / 2.
  33.         quickinvcos()    Calculate a fast inverse cosine.
  34.         rnd()        Random number generator between 0 and 1.
  35.         rand1()        Random number generator between -1 and 1.
  36.         grand()        Approximate gaussian random number generator.
  37.         sample_ray()    Take a ray somewhere inside a solid angle.
  38.         trace_a_ray()    Trace a single ray.
  39.         trace()        Trace a single ray inside a solid angle.
  40.         raytrace()    Ray trace the whole picture.
  41.  
  42. vector.c:    vadd()        vector addition.
  43.         vsub()        vector subtraction.
  44.         vneg()        vector negation.
  45.         svproduct()    scalar - vector product.
  46.         vdot()        dot product.
  47.         vcross()    cross product.
  48.         norm()        normalize a vector.
  49.  
  50. ray.h:        Include file for every file used in the raytracer.
  51.  
  52. vector.h:    Include file for every file using vectors.
  53.  
  54.  
  55.  
  56.     The ray tracer is written so it can be easily understood (at least
  57. that version), and it is fully commented.  Nevertheless, probably it won't
  58. be understood by a newcomer.  
  59.  
  60.     The format of the input file is as follows:
  61.  
  62. <fov>
  63. <eye>
  64. <dir>
  65. <up>
  66. <time>
  67. <background>
  68. <iter>
  69. <light>
  70. <nos> <nosq>
  71. x y z r [ambient] [diff] [spec] refl r g b refr r g b width index
  72.     refl_diffuse refr_diffuse tx ty tz
  73. x y z x y z x y z [ambient] [diff] [spec] refl r g b refr r g b width index
  74.     refl_diffuse refr_diffuse tx ty tz
  75.  
  76. where:
  77.  
  78. fov        field of view
  79. eye        x y z components of the eye position
  80. dir        x y z components of the eye direction
  81. up        x y z components of the up vector
  82. time        start and end time of the picture
  83. background    a character specifying the background cuing as follows:
  84.         n: no cuing.  Background has a constant intensity of 0.2
  85.         x: the intensity of the background depends of the x direction.
  86.         y: the intensity of the background depends of the y direction.
  87.         z: the intensity of the background depends of the z direction.
  88. iter        number of samples per pixel.
  89. light        x y z components and solid angle of the light source.
  90. nos        number of spheres
  91. nosq        number of squares
  92. [ambient]    r g b components of ambient
  93. [diff]        r g b components of diffuse
  94. [spec]        r g b components of specular
  95. refl r g b    reflection ratio and color of the reflection
  96. refr r g b    refraction ratio and color of the refraction
  97. width        specular width exponent
  98. index        index of refraction
  99. refl_diffuse    angle of diffusion when reflecting
  100. refr_diffuse    angle of diffusion when refracting
  101. tx ty tz    velocities on the specified axes.
  102.  
  103. Hints:
  104.     Each frame is a snapsot of a given time length.  The time limits
  105. are specified in the input file.  Each object has the capability to move
  106. during that time in a strait line.  Motion blur is then observed.  If you
  107. specify only one sample per pixel, then the blur won't be so good since
  108. it evaluates the color of the ray with only one try.  The more samples the
  109. better, altough anything more than 20 or 30 doesn't do any good.  5 is a
  110. good approximation.  You can produce penumbras by specifying an angle in
  111. the light source.  That deviates from real life where each life has an area
  112. and the further away you are from the light source, the smaller the penumbras.
  113. Here, the size of the blurred shadow does not depend on the distance from
  114. the light source.  The refl_diffuse and refr_diffuse produce non-sharp
  115. reflections and refractions.  The argument is in degrees.  Anything less
  116. than 15 or 20 is good, altough the closer to zero the better you can see it.
  117.  
  118. Known bugs:
  119.     Polygons appear completely shadowd if the order of the vertices
  120. is not right.  I always forget which is the right order.
  121.  
  122.  
  123. ----
  124.     The square is defined by only 3 of its points.  The first and the
  125. second vertices specify one of the sides, and the first and third specify
  126. the second.  If you assume that second and third specify a side, then you
  127. probably won't get the right result.
  128.  
  129.     The format of the output file is simple.  In the beginning there are
  130. 2 integers (that can be read with fread() on a SUN) showing xsize and ysize
  131. of the picture.  After that follow the pixels in scan-line order.  Each pixel
  132. uses 3 bytes (one for red, green and blue), totalling 16777216 colors.  You
  133. can change the format of that file to tailor your needs.  It can be done
  134. easily by changing the funcion raytrace() in file trace.c
  135.  
  136.  
  137.     If you want you can inform me with any bugs that the program might have
  138. or any features that you want the upcoming versions to have.
  139.                         Good luck!
  140.  
  141.  
  142.     George Kyriazis
  143.     kyriazis@turing.cs.rpi.edu
  144.     kyriazis@yy.cicg.rpi.edu
  145.